package com.erlang4j.internal.adapters;

import java.util.concurrent.atomic.AtomicInteger;

import javax.swing.SwingUtilities;

import junit.framework.Assert;

import com.erlang4j.api.IGetData;
import com.erlang4j.api.adapters.MessageAdapter;
import com.erlang4j.api.process.IProcess;
import com.erlang4j.api.process.IProcessWithState;

public class MockAdapter extends MessageAdapter {

	public IGetData context;
	public AtomicInteger count = new AtomicInteger(0);
	public IProcess process;

	public MockAdapter(String pattern) {
		super(pattern);
	}

	@Override
	public void process(IProcessWithState process,IGetData data) throws Exception {
		this.process = process;
		this.context = data;
		count.incrementAndGet();
		checkSwingThead();
	}

	protected void checkSwingThead() {
		Assert.assertFalse(SwingUtilities.isEventDispatchThread());
	}

	public int getCount() {
		return count.intValue();
	}


}